import { ecs } from 'db://app-game/libs/ecs/ECS';
import { Account } from '../../biz/account/Account';
import { LocalStorageManager } from '../../biz/storage/LocalStorageManager';
import { InitResComp } from './bll/InitResSystem';

/**
 * 游戏进入初始化模块
 * 1、热更新
 * 2、加载默认资源
 */
@ecs.register('Initialize')
export class Initialize extends ecs.Entity {
  // 数据层
  InitRes!: InitResComp;
  /** 账号管理 */
  account: Account = null!;
  /** 本地储存管理 */
  storage: LocalStorageManager = null!;
  init() {
    // 1.账号模块为初始化模块的子实体对象
    this.account = ecs.getEntity<Account>(Account);
    this.addChild(this.account);

    // 2.初始化本地存储
    this.storage = ecs.getEntity<LocalStorageManager>(LocalStorageManager);
    this.addChild(this.storage);

    // 2.初始化游戏公共资源
    this.add(InitResComp);
  }
}
